@keyframes slimsearch-fade-in {
  from {
    opacity: 0.2;
  }

  to {
    opacity: 1;
  }
}

.slimsearch-modal-wrapper {
  position: fixed;
  inset: 0;
  z-index: 997;

  display: flex;
  align-items: center;
  justify-content: center;

  overflow: auto;

  cursor: default;
}

.slimsearch-mask {
  position: fixed;
  inset: 0;
  z-index: 998;

  backdrop-filter: blur(10px);

  animation: 0.25s slimsearch-fade-in;
}

.slimsearch-modal {
  position: absolute;
  z-index: 999;

  display: flex;
  flex-flow: column;

  width: calc(100% - 6rem);
  max-width: 50em;
  border-radius: 10px;

  background: var(--vp-c-bg);
  box-shadow: 2px 2px 10px 0 var(--vp-c-shadow);

  transition: background var(--vp-t-color);

  animation: 0.15s pwa-opened;

  @media (max-width: 1280px) {
    animation: 0.25s pwa-mobile;
  }

  @media (max-width: 719px) {
    inset: 0;

    box-sizing: border-box;
    width: 100%;
    max-width: unset;
    padding: env(--safe-area-inset-top) env(--safe-area-inset-right)
      env(--safe-area-inset-bottom) env(--safe-area-inset-left);
  }
}

.slimsearch-box {
  display: flex;
  margin: 1rem;

  form {
    position: relative;
    display: flex;
    flex: 1;
  }

  label {
    position: absolute;
    inset-inline-start: 0.5rem;
    top: calc(50% - 0.75rem);
    color: var(--vp-c-accent);

    .search-icon {
      width: 1.5rem;
      height: 1.5rem;
    }
  }
}

.slimsearch-clear-button {
  position: absolute;
  inset-inline-end: 0.75rem;
  top: calc(50% - 10px);

  padding: 0;
  border-width: 0;

  background: transparent;
  color: var(--vp-c-accent-bg);

  cursor: pointer;

  &:hover {
    border-radius: 50%;
    background-color: rgb(0 0 0 / 10%);
  }
}

.slimsearch-close-button {
  display: none;

  margin-inline: 0.5rem -0.5rem;
  padding: 0.5rem;
  border-width: 0;

  background: transparent;
  color: var(--vp-c-text-mute);

  font-size: 1rem;

  cursor: pointer;

  @media (max-width: 719px) {
    display: block;
  }
}

.slimsearch-input {
  flex: 1;

  width: 0;
  margin: 0;
  padding-block: 0.25rem;
  padding-inline: 2.5rem 2rem;
  border: 0;
  border: 2px solid var(--vp-c-accent-bg);
  border-radius: 8px;

  background: var(--vp-c-bg);
  color: var(--vp-c-text);
  outline: none;

  font-size: 1.25rem;
  line-height: 2.5;

  appearance: none;

  &::-webkit-search-cancel-button {
    display: none;
  }
}

.slimsearch-suggestions {
  position: absolute;
  inset: calc(100% + 4px) 0 auto;
  z-index: 20;

  overflow: visible;
  overflow-y: auto;

  max-height: 50vh;
  margin: 0;
  padding: 0;
  border-radius: 0.5rem;

  background-color: var(--vp-c-bg);
  box-shadow: 2px 2px 10px 0 var(--vp-c-shadow);
  list-style: none;

  line-height: 1.5;
}

.slimsearch-suggestion {
  padding: 0.25rem 1rem;
  border-top: 1px solid var(--vp-c-border);
  cursor: pointer;

  &:first-child {
    border-top: none;
  }

  &.active,
  &:hover {
    background-color: var(--vp-c-bg-alt);
  }
}

.slimsearch-auto-complete {
  display: none;
  float: right;

  margin: 0 0.5rem;
  padding: 0.25rem;
  border: 1px solid var(--vp-c-border);
  border-radius: 0.25rem;

  box-shadow: 1px 1px 4px 0 var(--vp-c-shadow);

  font-size: 0.75rem;
  line-height: 1;

  .slimsearch-suggestion.active & {
    display: block;
  }
}

.slimsearch-result-wrapper {
  flex-grow: 1;

  overflow-y: auto;

  min-height: 40vh;
  max-height: calc(80vh - 10rem);
  padding: 0 1rem;

  @media (max-width: 719px) {
    min-height: unset;
    max-height: unset;
  }

  &.loading,
  &.empty {
    display: flex;
    align-items: center;
    justify-content: center;

    padding: 1.5rem;

    font-weight: 600;
    font-size: 1.3rem;
    text-align: center;
  }
}

.slimsearch-hints {
  margin-top: 1rem;
  padding: 0.75rem 0.5rem;
  box-shadow: 0 -1px 4px 0 var(--vp-c-shadow);
  line-height: 1;
}

.slimsearch-hint {
  display: inline-flex;
  align-items: center;
  margin: 0 0.5rem;

  kbd {
    margin: 0 0.5rem;
    padding: 2px;
    border: 1px solid var(--vp-c-border);
    border-radius: 4px;

    box-shadow: 1px 1px 4px 0 var(--vp-c-shadow);

    + kbd {
      margin-inline-start: -0.25rem;
    }
  }

  svg {
    display: block;
    width: 15px;
    height: 15px;
  }
}
